<template>
  <div>
      id:<input type="number" v-model.trim="userInfo.id"><br/>
用户名：<input type="text" v-model.trim="userInfo.username"><br/>
密码：<input type="text" v-model.trim="userInfo.pwd"><br/>
性别：<input type="radio" :value="0" v-model="userInfo.gendar">♂
     <input type="radio" :value="1" v-model="userInfo.gendar">♀<br/>
手机号：<input type="number" v-model="userInfo.phone"><br/>
头像：<input type="url" v-model="userInfo.imgurl"><br/>
 <button @click="goRegEdit">修改</button><br/>
  </div>
</template>

<script>
import request from '../request/index.js'
export default {
  data() {
    return {
        userInfo:{
        }
    };
  },
  created() {
      this.userInfo=this.$store.state.userInfo
         console.log(this.$store.state.userInfo.gendar)
       //console.log(this.userInfo)
  },
  methods: {
       async goRegEdit(){
            const {data:res}=await request({url:"/users/edit",method:"post",data:{data:JSON.stringify(this.userInfo)}})
            if(res.status!=0)alert('修改失败')
            alert('修改成功')
            this.$store.commit("saveUserInfo",this.userInfo)
            this.$router.push("/myuser");
       }
  },
};
</script>
<style scoped>
</style>